<!--{subtemplate inc/header}-->
<script type="text/javascript">
<!--{dynamic getSiteDynamic args=$site['id']}-->
</script>
<script type="text/javascript" src="{PUBLIC_PATH}js/listtable.js"></script>
<div id="sysmsg-box">
	<div id="sysmsg-error" class="sysmsg{if $error == ''} hidden{/if}">
		<div><span class="fl">$error</span><span class="close">关闭</span></div>
	</div>
	<div id="sysmsg-success" class="sysmsg{if $success == ''} hidden{/if}">
		<div><span class="fl">$success</span><span class="close">关闭</span></div>
	</div>
</div>
<div class="blank9"></div>
<div class="hbox">
	<div id="body-left" class="fl">
		<div id="site-show">
			<div class="ss-img">
				<p>
					<!--{if !empty($site['site_img'])}-->
					<img src="{SITE_PATH}{$site[site_img]}" width="380" />
					<!--{else}-->
					<img src="{TPL_PATH}images/noimg.gif" width="380" />
					<!--{/if}-->
				</p>
			</div>
			<div class="ss-info">
				<h1>$site[name]</h1>
				<div id="site_star" class="ss-star">
					<div class="star"><div style="width:{echo floatval($site['score']) * 20}%"></div></div>
					<strong>$site[score]</strong>
					<a href="#message" class="message">参加评论</a>
				</div>
				<div class="ss-link">
					<a href="$site[go_url]">{echo getUrlHost($site['url'])}</a>
				</div>
				<div class="ss-attrs"> 
					<p>点击总量：<span><script type="text/javascript">document.write(siteDynamic.click_count);</script></span></p>
					<p>推荐总量：<span id='best_count'><script type="text/javascript">document.write(siteDynamic.best_count);</script></span></p>
					<p>定制人数：<span id='custom_count'><script type="text/javascript">document.write(siteDynamic.custom_count);</script></span></p>
				</div>
				<div class="ss-btns">
					<a href="$site[go_url]"><img src="{TPL_PATH}images/s1.gif" /></a>
					<a id="site-best" href="javascript:;" type="SITE_BEST" rel="best_count" style="margin:0 0 0 10px;"><img src="{TPL_PATH}images/s3.gif" /></a>
					<a id="site-custom" href="javascript:;" type="SITE_CUSTOM" rel="custom_count" style="margin:0 0 0 10px;"><img src="{TPL_PATH}images/s4.gif" /></a>
				</div>
			</div>
			<div class="ss-content">
				<div class="title">{$site['name']}简介</div>
				<div class="content">
					$site[content]
				</div>
			</div>
		</div>
		<div class="blank9"></div>
		<div class="show-tabs">
			<div class="tabs-title">
				<a class="current" rel="message" href="javascript:;">网站评论</a>
			</div>
			<div class="tabs-body" id="tabs_body">
				<div id="messagebox" class="tabs-item" rel="message">
					<div class="list" id="site_comment_list"></div>
					<div class="blank20"></div>
					<div class="add">
						<!--{dynamic getCommentForm args=1}-->
					</div>
					<div class="blank12"></div>
				</div>
			</div>
		</div>
	</div>
	<div id="body-right" class="fr">
	<!--{subtemplate inc/common/right}-->
	</div>
</div>
<script type="text/javascript">
var commentLT;
var siteID = $site[id];
var siteName = "$site[name]";

jQuery(function($){
	commentLT = new ListTable();
	commentLT.url = SITE_PATH + "/services/ajax.php?action=get_site_comment";
	commentLT.filter.rec_id = siteID;
	commentLT.filter.pageSize = 10;
	commentLT.filter.LT = 'commentLT';
	commentLT.resultFun = getCommentListResult;
	commentLT.loadFun = getCommentListLoading;
	
	$("#comment-add-form").submit(function(){
		if($.trim($("#content").val()).length == 0)
		{
			$.showErr("请填写评论内容");
			$("#content").focus();
			return false;
		}
		
		var query = new Object();
		query.rec_id = siteID;
		query.rec_name = siteName;
		query.content = $.trim($("#content").val());
		query.score = $(".starlabel input:checked").val();
		query.isajax = 1;
		query.action = "add_site_comment";
		
		$.showLoading("#tabs_body");
		
		$.ajax({
			type: "POST",
			dataType: "json",
			cache:false,
			url: SITE_PATH + "/services/ajax.php",
			data:query,
			success: function(data){
				if(data.status == 1)
				{
					commentLT.GotoPage(1);
				}
				else
				{
					alert(data.msg);
					$.closeLoading("#tabs_body");
				}
			}
		});
		
		return false;
	});
	
	$("#site-best,#site-custom").click(function(){
		var query = new Object();
		query.site_id = siteID;
		query.site_name = siteName;
		query.action = "site_handler";
		query.type = this.getAttribute("type");
		
		var rel = this.getAttribute("rel");
		
		$.showLoading("#site-show");
		$.ajax({
			url: SITE_PATH + "/services/ajax.php",
			data: query,
			dataType:"json",
			success:function(data){
				$.closeLoading("#site-show");
				if(data.status == 1)
				{
					if(query.type == "SITE_BEST")
					{
						$.showSuccess("推荐成功");
						$("#"+rel).html(siteDynamic.best_count + 1);
					}
					else
					{
						$.showSuccess("定制成功");
						$("#"+rel).html(siteDynamic.custom_count + 1);
					}
				}
				else if(data.status == 2)
				{
					if(query.type == "SITE_BEST")
						$.showErr("你已经推荐过此网站");
					else
						$.showErr("你已经定制过此网站");
				}
				else if(data.status == 3)
				{
					$.showErr('请先&nbsp;<a target="_blank" href="{u user/login}" style="color:#690;">登陆</a>&nbsp;或&nbsp;<a target="_blank" href="{u user/reg}" style="color:#690;">注册</a>!');
				}
			}
		});
		
	});
	
	commentLT.GotoPage(1);
});

function getCommentListResult(data)
{
	$.closeLoading("#tabs_body");
	$("#site_star .star div").width((data.score * 20) + '%');
	$("#site_star strong").html(data.score);
	$("#site_comment_list").html(data.html);
}

function getCommentListLoading(data)
{
	$.showLoading("#tabs_body");
}
</script>
<!--{subtemplate inc/footer}-->